const http = require('../app/util/query')
const proxys = require('../app/proxy/index')

http.get('userFund/getUserFunds').then((res) => {
  res.data.list.forEach(async (item) => {
    const newRecord = []
    item.position_record.forEach((subItem) => {
      newRecord.push({
        cost: subItem.cost,
        shares: subItem.shares,
        confirm_date: subItem.confirm_date
      })
    })
    await proxys.UserFund.newAndSave({
      position_record: newRecord,
      user_name: 'xiaobxia',
      fund_code: item.code,
      strategy: item.strategy
    })
  })
})
